package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper{
    Page<Dish> PageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 插入菜品
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 根据id进行查询
     * @param id
     */
    @Select("select * from dish where id=#{id}")
    Dish getByid(Long id);

    /**
     * 根据主键删除菜品中的数据
     * @param id
     */
    @Delete("delete from dish where id=#{id}")
    void Delate(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    @Select("select *from dish where category_Id = #{id} ")
    List<Dish> FindDishByDishId(Integer id);

    Integer countByMap(Map map);

    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> GetUserDishList(Long categoryId);

    @Select("select * from dish where id = #{dishId}")
    Dish getById(Long dishId);
}
